package cn.com.db.service;

import cn.com.db.model.Parts;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PartsService extends BaseService {

    public Boolean isExist(String id){
        if (StringUtils.isBlank(id)){
            return false;
        }
        return getPartsById(id)!=null;
    }

    public Parts getPartsById(String id){
        return partsDao.getPartsById(id);
    }

    public void createParts(Parts parts){
        partsDao.createParts(parts);
    }

    public List<Parts> getParts(String parent){
        return partsDao.getParts(parent);
    }

    public Integer countParts(String parent){
        return partsDao.countParts(parent);
    }

    @Transactional
    public void updateParts(Parts parts){
        partsDao.update(parts);
    }


}
